package com.homework.ch10;

/**
 * @author yuxi
 * @version 1.0
 * @date 2025/10/11
 * @Description:
 */
public class Test3 {
    public static void main(String[] args) {
        Runnable r=new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 100; i++) {
                    System.out.println(Thread.currentThread().getName()+" : "+i);
                    try {
                        Thread.sleep(100);
                    } catch (InterruptedException e) {
                        //e.printStackTrace();
                        System.out.println(e.getMessage());
                    }
                }
            }
        };
        ThreadGroup group=new ThreadGroup("线程组1");
        Thread t1=new Thread(group,r,"t1线程");
        System.out.println(t1.getState());
        t1.start();
        System.out.println(t1.getState());
        System.out.println(t1.getState());
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            //e.printStackTrace();
            System.out.println(e.getMessage());
        }
        System.out.println(t1.getState());
        System.out.println(t1.getState());

        group.destroy();
        System.out.println(t1.getState());
    }
}
